home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / prolog1.arc / GRRULES.PRO < prev    next >
Encoding:
Text File  |  1985-04-26  |  1.0 KB  |  35 lines

  1. /* This is just a program fragment that illustrates the use
  2. of user definable operators. The ?-op declarations below are
  3. actually executed every time this module is loaded in, thus
  4. enabling the particular operators. Nothing to ask this one. */
  5.  
  6.  
  7.  
  8. ?-op( 100, xfx, '$' ).
  9. ?-op( 150, xfy, '->' ).
  10.  
  11. sentence( P ) --> noun_phrase(X,P1,P), verb_phrase(X,P1).
  12.  
  13. noun_phrase(X, P1, P ) -->
  14.    determiner(X,P2,P1,P), noun( X, P3 ),
  15.    rel_clause( X, P3, P2 ).
  16. noun_phrase( X, P, P ) --> proper_noun( X ).
  17.  
  18. verb_phrase( X, P ) --> trans_verb(X,Y, P1), noun_phrase(Y, P1, P ).
  19. verb_phrase( X, P ) --> intrans_verb(X, P ).
  20.  
  21. rel_clause(X,P1,(P1$P2)) --> [that], verb_phrase(X, P2).
  22. rel_clause(_, P, P) --> [].
  23.  
  24. determiner(X, P1, P2, all(X, (P1->P2))) --> [every].
  25. determiner(X, P1, P2, exists(X,(P1$P2))) --> [a].
  26.  
  27. noun(X, man(X) ) --> [man].
  28. noun(X, woman(X)) --> [woman].
  29.  
  30. proper_noun(john) --> [john].
  31.  
  32. trans_verb(X, Y, loves(X,Y)) --> [loves].
  33.  
  34. intrans_verb(X, lives(X) ) --> [lives].
  35.